function ajax(url) {
    return new Promise(function (resolve, reject) {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", url);
        xhr.responseType = "json";
        xhr.onload = function () {
            if (this.status === 200) {
                resolve(this.response);
            } else {
                reject(new Error(this.statusText));
            }
        };
        xhr.send();
    });
}
var promise = Promise.all([ajax("/api/users.json"), ajax("/api/posts.json")]);

// promise
//     .then((values) => console.log(values))
//     .catch(function (error) {
//         console.log(error);
//     });

ajax("/api/urls.json")
    .then((value) => {
        const urls = Object.values(value);
        const tasks = urls.map((url) => ajax(url));
        return Promise.all(tasks);
    })
    .then((values) => {
        console.log(values);
    });
